package export.monster
{
	import base.*;
	
	import com.dusk.util.ResUtil;
	
	import export.bullet.*;
	
	import flash.display.*;
	import flash.geom.*;
	
	public class Monster35 extends BaseMonster
	{
		
		public function Monster35()
		{
			super();
			this.normalAttackRate = 0.6;
			this.horizonSpeed = 5;
			this.setHp(67000);
			this.setSHp(67000);
			this.protectedParamsObject.mysee = 5 * 60;
			this.protectedParamsObject.isattback = 50;
			this.mavo.attackRange = 250;
			this.mavo.alertRange = 1000;
			this.protectedParamsObject.def = 48;
			this.protectedParamsObject.exp = 500;
			this.protectedParamsObject.gxp = 250;
			this.protectedParamsObject.mDef = 0.214;
			this.attackBackInfoDict["hit1"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-6, -5],
				"attackInterval" : 999,
				"power"          : 350,
				"attackKind"     : "physics"
			};
			this.attackBackInfoDict["hit2_2"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-3, 0],
				"attackInterval" : 999,
				"power"          : 600,
				"attackKind"     : "magic"
			};
			this.attackBackInfoDict["hit2_3"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-3, 0],
				"attackInterval" : 999,
				"power"          : 600,
				"attackKind"     : "magic"
			};
			this.attackBackInfoDict["hit3"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-15, 0],
				"attackInterval" : 8,
				"power"          : 400,
				"attackKind"     : "magic"
			};
			this.mavo.isBoss = true;
			this.mavo.monsterName = "土行孙";
			this.setAction("idle");
			this.protectedParamsObject.probability = 0.25;
			this.mavo.fallList = [{"name": "xltzzzs", "bigtype": "dj"}, {"name": "xleyzzs", "bigtype": "dj"}];
			this.skillCD1 = [gc.frameClips * 6, gc.frameClips * 12];
			this.skillCD2 = [gc.frameClips * 3, gc.frameClips * 8];
		}
		
		override protected function initBBDC():void
		{
			var _loc1_:* = null;
			var _loc2_:Array = BaseBitmapDataPool.getBitmapDataArrayByName("Monster35");
			if (_loc2_)
			{
				_loc1_ = {"name": "body", "source": _loc2_};
				bbdc = new BaseBitmapDataClip([_loc1_], 200, 200, new Point(0, 0));
				bbdc.setOffsetXY(0, -25);
				bbdc.setFrameStopCount([[2, 2, 2, 3, 2, 4], [2, 2, 2, 3, 2, 4], [15], [2, 2, 2, 2, 10], [2, 2, 2, 2, 10], [2, 2, 2, 96], [9, 3, 2, 8], [24]]);
				bbdc.setFrameCount([6, 6, 1, 5, 5, 4, 4, 1]);
				bbdc.setEnterFrameCallBack(this.enterFrameFunc, this.exitFrameFunc);
				bbdc.setAddScriptWhenFrameOver(this.scriptFrameOverFunc);
				this.bodyContainer.addChild(bbdc);
				return;
			}
			throw new Error("Monster35--BitmapData Error!");
		}
		
		override protected function initCollideArea():void
		{
			this.colipse = ResUtil.getNewObj("ObjectBaseSprite") as Sprite;
			this.colipse.visible = false;
			this.addChild(this.colipse);
		}
		
		override public function setAction(param1:String):void
		{
			super.setAction(param1);
			var _loc2_:Point = this.bbdc.getCurPoint();
			switch (param1)
			{
				case "idle":
					if (_loc2_.y != 0)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(0);
					}
					this.bbdc.setState(param1);
					break;
				case "walk":
					if (_loc2_.y != 1)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(1);
					}
					this.bbdc.setState(param1);
					break;
				case "hurt":
					if (_loc2_.y != 2)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(2);
					}
					this.bbdc.setState(param1);
					break;
				case "hit1":
					if (_loc2_.y != 4)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(4);
					}
					this.bbdc.setState(param1);
					break;
				case "hit2_1":
					if (_loc2_.y != 5)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(5);
					}
					this.bbdc.setState(param1);
					break;
				case "hit2_2":
					if (_loc2_.y != 6)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(6);
					}
					this.bbdc.setState(param1);
					break;
				case "hit3":
					if (_loc2_.y != 7)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(7);
					}
					this.bbdc.setState(param1);
					break;
				case "dead":
					this.setStatic();
					if (_loc2_.y != 3)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(3);
					}
					this.bbdc.setState(param1);
			}
		}
		
		override protected function scriptFrameOverFunc(param1:int):void
		{
			var _loc2_:String = this.bbdc.getState();
			switch (_loc2_)
			{
				case "walk":
					this.bbdc.setFramePointX(0);
					break;
				case "idle":
					this.bbdc.setFramePointX(0);
					break;
				case "hit1":
					this.setAction("idle");
					break;
				case "hit2_1":
					this.setInvincible(48);
					this.setAction("hit2_2");
					break;
				case "hit2_2":
					this.setAction("idle");
					break;
				case "hit3":
					this.setAction("idle");
					break;
				case "hurt":
					this.setStatic();
					this.setAction("idle");
					break;
				case "dead":
					this.dropAura();
					this.destroy();
			}
		}
		
		override protected function enterFrameFunc(param1:Point):void
		{
			var _loc2_:String = this.bbdc.getState();
			var _loc3_:uint = this.getBBDC().getDirect();
			switch (_loc2_)
			{
				case "hit1":
					if (param1.x == 2)
					{
						if (this.bbdc.getCurFrameCount() == 2)
						{
							this.doHit1_1(_loc3_);
							break;
						}
						break;
					}
					if (param1.x == 4)
					{
						if (this.bbdc.getCurFrameCount() == 10)
						{
							this.doHit1_2(_loc3_);
							break;
						}
						break;
					}
					break;
				case "hit2_1":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 2)
						{
							this.doHit2_1(_loc3_);
							break;
						}
						break;
					}
					if (param1.x == 3)
					{
						if (this.bbdc.getCurFrameCount() == 96)
						{
							this.doHit2_2(_loc3_);
						}
						this.setStatic();
						break;
					}
					break;
				case "hit2_2":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 9)
						{
							this.x = this.curAttackTarget.x;
							this.doHit2_1(_loc3_);
							this.doHit2_3(_loc3_);
							break;
						}
						break;
					}
					break;
				case "hit3":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 24)
						{
							this.doHit3(_loc3_);
						}
						if (_loc3_ == 0)
						{
							this.velocity.x = -15;
							break;
						}
						this.velocity.x = 15;
						break;
					}
			}
		}
		
		override protected function beforeSkill1Start():Boolean
		{
			return Boolean(this.curAttackTarget) && AUtils.GetDisBetweenTwoObj(this.curAttackTarget, this) < 10 * 60;
		}
		
		override protected function beforeSkill2Start():Boolean
		{
			return Boolean(this.curAttackTarget) && AUtils.GetDisBetweenTwoObj(this.curAttackTarget, this) < 400;
		}
		
		override protected function releSkill1():void
		{
			
			this.faceToTarget();
			this.setInvincible(110);
			this.setAction("hit2_1");
			this.lastHit = "hit2_1";
		}
		
		override protected function releSkill2():void
		{
			
			this.faceToTarget();
			this.setInvincible(35);
			this.setAction("hit3");
			this.lastHit = "hit3";
		}
		
		override protected function exitFrameFunc(param1:Point):void
		{
		}
		
		override protected function myIntelligence():void
		{
			if (!this.isBeAttacking())
			{
				super.myIntelligence();
			}
		}
		
		override public function isCanMoveWhenAttack():Boolean
		{
			return this.curAction == "hit3";
		}
		
		override public function isAttacking():Boolean
		{
			return this.curAction == "hit1" || this.curAction == "hit2_1" || this.curAction == "hit2_2" || this.curAction == "hit3";
		}
		
		override public function destroy():void
		{
			var _loc1_:* = null;
			var _loc2_:int = 0;
			var _loc3_:* = null;
			super.destroy();
			if (this.getHp() <= 0)
			{
				if (gc.pWorld.getBaseLevelListener() is StageListener81)
				{
					StageListener81(gc.pWorld.getBaseLevelListener()).showJwealSprite();
				}
				if (this.mavo.isBoss)
				{
					_loc1_ = gc.pWorld.getTransferDoorArray();
					_loc2_ = 0;
					while (_loc2_ < _loc1_.length)
					{
						_loc3_ = _loc1_[_loc2_];
						_loc3_.visible = true;
						_loc2_++;
					}
				}
			}
		}
		
		private function doHit1_1(param1:uint):void
		{
			var _loc2_:SpecialEffectBullet = new SpecialEffectBullet("Monster35Bullet1_1");
			if (param1 == 0)
			{
				_loc2_.x = this.x - 155;
			}
			else
			{
				_loc2_.x = this.x + 155;
			}
			_loc2_.y = this.y - 140;
			_loc2_.setOwner(this);
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit1");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHit1_2(param1:uint):void
		{
			var _loc2_:SpecialEffectBullet = new SpecialEffectBullet("Monster35Bullet1_2");
			if (param1 == 0)
			{
				_loc2_.x = this.x - 135;
			}
			else
			{
				_loc2_.x = this.x + 135;
			}
			_loc2_.y = this.y - 75;
			_loc2_.setOwner(this);
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit1");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHit2_1(param1:uint):void
		{
			var _loc2_:SpecialEffectBullet = new SpecialEffectBullet("Monster35Bullet2_1");
			if (param1 == 0)
			{
				_loc2_.x = this.x - 65;
			}
			else
			{
				_loc2_.x = this.x + 65;
			}
			_loc2_.y = this.y + 15;
			_loc2_.setOwner(this);
			_loc2_.setDisable();
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit2_1");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHit2_2(param1:uint):void
		{
			var _loc2_:* = null;
			var _loc3_:* = null;
			var _loc4_:* = 0;
			for each (_loc2_ in this.magicBulletArray)
			{
				if (_loc2_.getImcName() == "Monster35Bullet2_1")
				{
					_loc4_ = uint(gc.gameScene.getChildIndex(_loc2_));
				}
			}
			if (_loc4_ > 0)
			{
				_loc3_ = new SpecialEffectBullet("Monster35Bullet2_2");
				if (param1 == 0)
				{
					_loc3_.x = this.x - 90;
				}
				else
				{
					_loc3_.x = this.x + 90;
				}
				_loc3_.y = this.y - 180;
				_loc3_.setRole(this);
				_loc3_.setDirect(param1);
				_loc3_.setAction("hit2_2");
				gc.gameScene.addChildAt(_loc3_, _loc4_);
				this.magicBulletArray.push(_loc3_);
			}
		}
		
		private function doHit2_3(param1:uint):void
		{
			var _loc2_:* = null;
			var _loc3_:* = null;
			var _loc4_:* = 0;
			for each (_loc2_ in this.magicBulletArray)
			{
				if (_loc2_.getImcName() == "Monster35Bullet2_1")
				{
					_loc4_ = uint(gc.gameScene.getChildIndex(_loc2_));
				}
			}
			if (_loc4_ > 0)
			{
				_loc3_ = new SpecialEffectBullet("Monster35Bullet2_3");
				if (param1 == 0)
				{
					_loc3_.x = this.x - 80;
				}
				else
				{
					_loc3_.x = this.x + 80;
				}
				_loc3_.y = this.y - 160;
				_loc3_.setRole(this);
				_loc3_.setDirect(param1);
				_loc3_.setAction("hit2_3");
				gc.gameScene.addChildAt(_loc3_, _loc4_);
				this.magicBulletArray.push(_loc3_);
			}
		}
		
		private function doHit3(param1:uint):void
		{
			var _loc2_:FollowTargetBullet = new FollowTargetBullet("Monster35Bullet3");
			if (param1 == 0)
			{
				_loc2_.x = this.x - 120;
			}
			else
			{
				_loc2_.x = this.x + 2 * 60;
			}
			_loc2_.y = this.y - 90;
			_loc2_.setOwner(this);
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit3");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
	}
}
